export default {
  install(Vue) {
    (Vue.prototype.showAlert = function (msg, className) {
      Toast({
        message: msg,
        iconClass: className,
        duration: 2000,
      });
    }),
      /**
       * 设置登录标志
       * @param {Boolean} flag 设置登录标志 true or false
       */
      (Vue.prototype.setLogin = function (flag) {
        if (typeof flag === "boolean") {
          localStorage.setItem("login_flag", flag);
          // sessionStorage.setItem("login_flag", flag);
        }
      }),
      //设置是否判断登录
      (Vue.prototype.setIsLogin = function (flag) {
        if (typeof flag === "boolean") {
          localStorage.setItem("isLogin", flag);
          // sessionStorage.setItem("isLogin", flag);
        }
      }),
      //判断参数是否为空
      (Vue.prototype.isEmpty = function (B) {
        switch (typeof B) {
          case "undefined":
            return true;
          case "string":
            if (B.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, "").length == 0) {
              return true;
            }
            break;
          case "boolean":
            if (!B) {
              return true;
            }
            break;
          case "number":
            if (isNaN(B)) {
              return true;
            }
            break;
          case "object":
            if (null === B || B.length === 0) {
              return true;
            }
            for (var A in B) {
              return false;
            }
            return true;
        }
        return false;
      });
  },
};
